export const FILE_UPLOAD_BASE = (import.meta.env.VITE_UPLOAD_BASE || 'http://localhost:81/dav') as string
export const FILE_ACCESS_BASE = (import.meta.env.VITE_FILE_BASE || 'http://localhost:81/files') as string

const AUTH = import.meta.env.VITE_UPLOAD_AUTH as string | undefined
const USER = import.meta.env.VITE_UPLOAD_USER as string | undefined
const PASS = import.meta.env.VITE_UPLOAD_PASS as string | undefined

export function getUploadHeaders(): Record<string, string> {
  if (AUTH && AUTH.trim()) return { Authorization: AUTH.startsWith('Basic ') ? AUTH : `Basic ${AUTH}` }
  if (USER && PASS) return { Authorization: `Basic ${btoa(`${USER}:${PASS}`)}` }
  return {}
}
